<include file="Public:header_new"/>
<div class="usernewout">
	<div class="usncont">
		<!--左侧菜单-->
		<include file="User:left"/>
		<!--左侧菜单-->
		<!--上方导航-->
		<include file="User:nav"/>
		<!--上方导航-->
		<div class="usnc_right">
			<div class="nameauth">
				<h1>{$Think.lang.User_chedlmm}</h1>
				<!-- <div style="color:#059ff5;text-align: center;margin-top: 20px;">{$Think.lang.g_pwd_notice}</div> -->
				<div class="rech_top" style="width: 600px;">
					<div class="rech_box">
						<div class="rech_bd safe_rech_bd">
							<ul>
								<li>
									<div class="rechmid" style="width: 600px;">
										<div class="rechipt_box">
											<label>{$Think.lang.g_pwd}{$Think.lang.sTrade_index_cnmh}</label>
											<div class="iptbox">
												<input type="password" class="rechipt" id="oldpassword" placeholder="" onkeyup="chkpwd();" maxlength="16" onblur="chkoldpassword();"/>
											</div>
										</div>

										<div class="rechipt_box">
											<label>{$Think.lang.g_pwd_new}{$Think.lang.sTrade_index_cnmh}</label>
											<div class="iptbox">
												<input type="password" id="newpassword" class="rechipt" placeholder="{$Think.lang.User_sixbyte}" onblur="if(this.placeholder == '')this.placeholder='{$Think.lang.User_sixbyte}';" onclick="if(this.placeholder == '{$Think.lang.User_sixbyte}')this.placeholder='';" onkeyup="chknewpwd();" maxlength="16" onblur="chknewpassword();"/>
											</div>
										</div>
										<div class="rechipt_box">
											<label>{$Think.lang.g_pwd_new_confim}{$Think.lang.sTrade_index_cnmh}</label>
											<div class="iptbox">
												<input type="password" id="repassword" class="rechipt" placeholder="{$Think.lang.User_sixbyte}" onblur="if(this.placeholder == '')this.placeholder='{$Think.lang.User_sixbyte}';" onclick="if(this.placeholder == '{$Think.lang.User_sixbyte}')this.placeholder='';" onkeyup="rechknewpwd();" maxlength="16" onblur="chkrepassword();"/>
											</div>
										</div>
										<div class="rechipt_box" id="email_div">
											<label>{$Think.lang.g_yx_verify}{$Think.lang.sTrade_index_cnmh}</label>
											  <div class="iptbox">
												  <input type="text" id="email_verify" value="" class="rechipt halfipt" maxlength="6"/>
												  <input type="button" id="regBtn" onclick="EmCode()" value="{$Think.lang.g_yx_rec_verify}" class="yzmbut">
													<if condition="$user['email'] eq '' || $user['email'] eq null">
													<p class="attention">{$Think.lang.g_pwd_no_bindyx}</p>
													<else />
													<p class="attention">* {$Think.lang.g_pwd_yx_recode} {$user['email']}</p>
													</if>
											  </div>
										  </div>
										<div class="dv_submit">
											<input type="button" id="btn-submit" value="{$Think.lang.User_save} " title="{$Think.lang.User_save} " onclick="Update()" />
										</div>
									</div>
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	$('input').focus(function () {
		var t = $(this);
		if (t.attr('type') == 'text' || t.attr('type') == 'password')
			t.css({'box-shadow': '0px 0px 3px #20212d', 'border': '1px solid #20212d', 'color': '#99A6BF'});
		if (t.val() == t.attr('placeholder'))
			t.val('');
	});
	$('input').blur(function () {
		var t = $(this);
		if (t.attr('type') == 'text' || t.attr('type') == 'password')
			t.css({'box-shadow': 'none', 'border': '1px solid #20212d', 'color': '#99A6BF'});
		if (t.attr('type') != 'password' && !t.val())
			t.val(t.attr('placeholder'));
	});

	function EmCode() {
	  layer.load(0, {shade: [0.5,'#8F8F8F']});
	    $('#regBtn').attr("disabled", "disabled");
	    $.post("{:U('Verify/passemail')}", {}, function (data) {
	    layer.closeAll();
	      if (data.status == 1) {
	        layer.msg(data.info, {
	          icon: 1
	        });
	        var obj = $('#regBtn');
	        var wait = 120;
	        var interval = setInterval(function () {
	          obj.css('backgroundColor', '#135f91');
	          obj.val(wait + '{$Think.lang.Finance_again} ');
	          wait--;
	          if (wait < 0) {
	            obj.removeAttr("disabled");
	            clearInterval(interval);
	            obj.val('{$Think.lang.Finance_hqyzm2} ');
	            obj.css('backgroundColor', '#135f91');
	          }
	          ;
	        }, 1000);
	      } else {
	        $('#regBtn').removeAttr("disabled");
	        layer.msg(data.info, {
	          icon: 2
	        });
	      }
	    }, "json");
	}

	function Update() {
		var oldpassword = $("#oldpassword").val();
	    var newpassword = $("#newpassword").val();
	    var repassword = $("#repassword").val();
    	var email_verify = $("#email_verify").val();

	    if (email_verify == "" || email_verify == null) {
	      layer.tips('{$Think.lang.g_yx_put_verfy} ', '#email_verify', {
	        tips: 3
	      });
	      return false;
	    }

	    if (newpassword == "" || newpassword == null) {
	      layer.tips('{$Think.lang.User_rsnewdlmm} ', '#newpassword', {
	        tips: 3
	      });
	      return false;
	    }

	    if (oldpassword == "" || oldpassword == null) {
	      layer.tips('{$Think.lang.User_rsolddlmm} ', '#oldpassword', {
	        tips: 3
	      });
	      return false;
	    }

	     if (repassword == "" || repassword == null) {
	      layer.tips('{$Think.lang.User_rsenterdlmm} ', '#repassword', {
	        tips: 3
	      });
	      return false;
	    }

		$.post("{:U('User/uppassword')}", {
			oldpassword: $('#oldpassword').val(),
			newpassword: $('#newpassword').val(),
			repassword: $('#repassword').val(),
			email_verify: email_verify
		}, function (data) {
			if (data.status == 1) {
				layer.msg(data.info, {icon: 1});
				window.location = "{:U('Login/loginout')}";
			} else {
				layer.msg(data.info, {icon: 2});
				if (data.url) {
					window.location = data.url;
				}
			}
		}, "json");
	}

	function chkpwd(){
		var password = $("#oldpassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(password)) {
			layer.tips('{$Think.lang.User_mmgs2} ','#oldpassword',{tips:3});
			var result = password.substring(0,password.length-1);
			$("#oldpassword").val(result);
		}
	}
	function chknewpwd(){
		var newpassword = $("#newpassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(newpassword)) {
			layer.tips('{$Think.lang.User_mmgs2} ','#newpassword',{tips:3});
			var result = newpassword.substring(0,newpassword.length-1);
			$("#newpassword").val(result);
		}
	}
	function rechknewpwd(){
		var repassword = $("#repassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(repassword)) {
			layer.tips('{$Think.lang.User_mmgs2} ','#repassword',{tips:3});
			var result = repassword.substring(0,repassword.length-1);
			$("#repassword").val(result);
		}
	}
	function chkoldpassword(){
		var oldpassword = $("#oldpassword").val();
		if(!oldpassword){
			layer.tips("{$Think.lang.User_rsolddlmm} ",'#oldpassword',{tips:3});
		}
	}
	function chknewpassword(){
		var newpassword = $("#newpassword").val();
		if(!newpassword){
			layer.tips("{$Think.lang.User_rsolddlmm} ",'#newpassword',{tips:3});
		}
	}
	function chkrepassword(){
		var repassword = $("#repassword").val();
		if(!repassword){
			layer.tips("{$Think.lang.User_rsolddlmm2} ",'#repassword',{tips:3});
		}
	}
	function chkmobileverify(){
		var mobileverify = $("#mobile_verify").val();
		if(!mobileverify){
			layer.tips("{$Think.lang.User_srsjyzm} ",'#mobile_verify',{tips:3});
		}
	}
	//菜单高亮
$('#user_index').addClass('on');
</script>
<include file="Public:footer_new"/>